#include <vector>
#include <stdfix.h>
#include <iostream>
using namespace std  ;


template<typename T>
void show(T array[],int length,int pro,int next){
    for(int i=0;i<length;i++){ 
        if(i==pro||i==next){
            cout<<"["<<array[i]<<"] ";
        }
        else{
            cout<<array[i]<<"   ";
        }
    }
    cout<<endl;
}

template<typename T>
void shell_sort(T array[], int length) {
    int h = 1;
    while (h < length / 2) {
        h = 2 * h + 1;
    }
    while (h >= 1) {
        for (int i = h; i < length; i++) {
            for (int j = i; j >= h && array[j] < array[j - h]; j -= h) {
                std::swap(array[j], array[j - h]);//交换
                //cout<<"h="<<h<<",j="<<j<<endl;
                show(array,length,j,j-h) ;
            }
        }
        h = h / 2;
    }
}

int main(){
    //printf("\033[**31m**红色\033[**0m**");
    //cout<<"\03[1,31mHello\03[0m"<<endl;
    int arr[]= { 22, 34, 3, 32, 82, 55, 89, 50, 37, 5, 64, 35, 9, 70 };
    int len=sizeof(arr)/sizeof(arr[0]);
    show(arr,len,-1,-1);
    shell_sort(arr,len);
    show(arr,len,-1,-1);
    return 0;
}